/*
 * @Author: szx
 * @Date: 2021-12-21 15:59:12
 * @LastEditTime: 2021-12-21 16:01:51
 * @Description:
 * @FilePath: \leetcode\100-199\101\101.js
 */
/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @return {boolean}
 */
var isSymmetric = function (root) {
    const check = (left, right) => {
        if (left == null && right == null) return true;
        else if ((left == null && right != null) || (left != null && right == null)) return false;
        else if (left.val != right.val) return false;
        return check(left.left, right.right) && check(left.right, right.left);
    };
    return check(root.left, root.right);
};
